#include "checkResult.h"


std::string CheckResult::detectCommandUpdatePicResponseInit()
{
    std::string strjson;
    Json::Value detectResponse, root;
    Json::StreamWriterBuilder writeBuild;
    std::ostringstream os;

    detectResponse["Command"] = "UpdatePic";
    detectResponse["Result"] = true;
    root["DetectResponse"] = Json::Value(detectResponse);

    std::unique_ptr<Json::StreamWriter> jsonWriter(writeBuild.newStreamWriter());
    jsonWriter->write(root,&os);
    strjson = os.str();
    return strjson;
}

//*** linux -> win 
//*** foreign body detect alarm
// linux -> win
Json::Value CheckResult::alarmBeatInit(const string ID, const string AlarmType, const int StartPosition,const int EndPosition,
                        const string AlarmLevel, const int DetailsSize, const string FileName, const string Description, 
                        const string CurrentTime, const string task_id)
{
    std::string jsonStr;
    Json::Value  AlarmInfomation , root;
    Json::StreamWriterBuilder writerBuilder;
    std::ostringstream os;

    AlarmInfomation["ID"] = ID;
    AlarmInfomation["AlarmType"] = AlarmType;
    AlarmInfomation["StartPosition"] = StartPosition;
    AlarmInfomation["EndPosition"] = EndPosition;
    AlarmInfomation["AlarmLevel"] = AlarmLevel;           //"Marjor"
    AlarmInfomation["DetailsSize"] = DetailsSize;
    AlarmInfomation["FileName"] = FileName;
    AlarmInfomation["Description"] = Description;
    AlarmInfomation["CurrentTime"] = CurrentTime;
    AlarmInfomation["Task_ID"] = task_id;

    root["AlarmInfomation"] = Json::Value(AlarmInfomation);
    return root;
}

//*** foreign body detect
// linux -> win
Json::Value CheckResult::unalarmBeatInit(const string ID, const string InfoType, const int LocalPosition, const string CurrentTime,
                           const int DetailsSize, const string FileName, const string Description, const string task_id )
{
    std::string jsonStr;
    Json::Value  unAlarmInfomation , root;
    Json::StreamWriterBuilder writerBuilder;
    std::ostringstream os;
    unAlarmInfomation["ID"] = ID;
    unAlarmInfomation["InfoType"] = InfoType;
    unAlarmInfomation["LocalPosition"] = LocalPosition;
    unAlarmInfomation["CurrentTime"] = CurrentTime;
    unAlarmInfomation["DetailsSize"] = DetailsSize;
    unAlarmInfomation["FileName"] = FileName;
    unAlarmInfomation["Description"] = Description;
    unAlarmInfomation["Task_ID"] = task_id;

    root["DeviceInfo"] = Json::Value(unAlarmInfomation);
    return root;
}





// temperature camera function
Json::Value CheckResult::tempAlarmBeatInit(const string id, const string task_id)
{
    std::string jsonStr;
    Json::Value  AlarmInfomation , root;
    Json::StreamWriterBuilder writerBuilder;
    std::ostringstream os;

    AlarmInfomation["ID"] = id;
    AlarmInfomation["AlarmType"] = "HighTemperature";
    AlarmInfomation["StartPosition"] = 1;
    AlarmInfomation["EndPosition"] = 2;
    AlarmInfomation["AlarmLevel"] = "Marjor";
    AlarmInfomation["DetailsSize"] = 123456;
    AlarmInfomation["FileName"] = "xx.jpg";
    AlarmInfomation["Description"] = "xxx";
    AlarmInfomation["CurrentTime"] = "2017-12-14 09:30:23";
    AlarmInfomation["Task_ID"] = task_id;

    root["AlarmInfomation"] = Json::Value(AlarmInfomation);
    return root;
}
Json::Value CheckResult::tempInfoBeatInit(const string id)
{
    std::string jsonStr;
    Json::Value  TunnelTemperature , root;
    Json::StreamWriterBuilder writerBuilder;
    std::ostringstream os;

    TunnelTemperature["ID"] = id;
    TunnelTemperature["Maximum"] = 0;
    TunnelTemperature["Minimal"] = 0;
    TunnelTemperature["Average"] = 0;
    TunnelTemperature["CurrentPosition"] = 0;
    TunnelTemperature["CurrentTime"] = "2017-12-14 09:30:23";

    root["TunnelTemperature"] = Json::Value(TunnelTemperature);
    return root;
}

